
          <script type="text/javascript">   
          function addMarkerAtCenter() {
    var marker = new google.maps.Marker({
        position: map.getCenter(),
        map: map
    });
    var text = 'Lat/Lng: ' + getCenterLatLngText();
    if(currentReverseGeocodeResponse) {
      var addr = '';
      if(currentReverseGeocodeResponse.size == 0) {
        addr = 'None';
      } else {
        addr = currentReverseGeocodeResponse[0].formatted_address;
      }
      text = text + '<br>' + 'address: <br>' + addr;
    }
    var infowindow = new google.maps.InfoWindow({ content: text });
    google.maps.event.addListener(marker, 'click', function() {
      infowindow.open(map,marker);
    });
  }
</script>
          
<div class=”row”>
      <body style="background:white">
                    
<div class="row buttons">
     
 <form method="post" action="<?=$_SERVER['PHP_SELF']?>">
<input type="SUBMIT" name="escuchar" value="Escuchar">
    </form>
    </div>

   
<?php



if(isset($_POST["escuchar"]))
{
$model->store_location(44,$latitude,$longitude,$map_zoom_level);
};




Yii::import('ext.jquery-gmap.*');
//echo $saludo;
$gmap = new EGmap3Widget();
$gmap->setSize(600, 400);

// base options
$options = array(
	'scaleControl' => true,
	'streetViewControl' => false,
	'zoom' => 10,
	'center' => array(0, 0),
	'mapTypeId' => EGmap3MapTypeId::ROADMAP,
	'mapTypeControlOptions' => array(
		'style' => EGmap3MapTypeControlStyle::DROPDOWN_MENU,
		'position' => EGmap3ControlPosition::TOP_RIGHT,
	),
	'zoomControlOptions' => array(
		'style' => EGmap3ZoomControlStyle::LARGE,
		'position' => EGmap3ControlPosition::BOTTOM_LEFT
	),
);
$gmap->setOptions($options);
//$options->mapTypeId = EGmap3MapTypeId::TERRAIN;









 $marker=new EGmap3Marker(array(
            'title'=>'Updateable marker',
            'draggable'=>true,
          ));
          $marker->latLng=array(-12.069123471020955,-77.0606765039063);
    //for capturing teh coordinates
          $marker->capturePosition(
            $model,
            'latitude',                           
            'longitude',
            array('visible','drag')
  
            );
          
          
      
echo ' <script type="text/javascript">
function captureMarkerPosition(marker)
{
 document.getElementById("Location_latitude").value=marker.getPosition().lat();
 document.getElementById("Location_longitude").value=marker.getPosition().lng();
}
</script>';

//-12.090353,-77.0224


          
          
          
          
          
           $gmap->map->captureZoom(
             $model,
             'map_zoom_level',
              true,
              array('class'=>'myCustomClass')
           );            
         

           
           
           
           
           
          $gmap->updateMarkerAddressFromModel(
           // the model object
           $model,
           array('name','address1','address2','state','zip'),
           array(
                'zoom'=>16,
               )     
 
         );


//$marker = new EGmap3Marker(array('title' => 'Registrar'));
//$marker->address = 'Jacksonville, FL';
//$marker->latLng = array(-12.090353, -77.0224);


 
 $marker->centerOnMap();
$marker->setMapZoom(11);
$gmap->add($marker);


$gmap->renderMap();
//$marker->capturePosition($model, $lat, $lng);
//$marker->addEvent('dragend', 'function(result){captureMarkerPosition'.'(result);}');

//
//$js = "function placeMarker(location) {
//            // first remove all markers if there are any
//            //deleteOverlays();
//            var map = $(this).gmap3('get'),
//            var marker = new google.maps.Marker({
//                position: location, 
//                map: map
//            });
//
//            // add marker in markers array
//            markersArray.push(marker);
//
//            //map.setCenter(location);
//        }";
////$marker->addEvent('click', $js);
//
////$gmap->map->addEvent('click',$js);
//
//
//
//$polyOptions = array(
//	'fillColor' => 'yellow',
//	'strokeColor' => 'red'
//);
//
//$rectangleOptions = array_merge(
//		$polyOptions, array('bounds' => array(40, -72, 42, -76))
//);
//$rectangle = new EGmap3Rectangle($rectangleOptions);
////$rectangle->centerOnMap();
////$gmap->add($rectangle);
//
//$polygon = new EGmap3Polygon($polyOptions);
//$polygon->paths = array(
//	array(18.466465, -66.118292),
//	array(32.321384, -64.75737),
//	array(25.774252, -80.190262),
//	array(25.774252, -80.190262),
//);
////$polygon->centerOnMap();
////$gmap->add($polygon);
//
//$polyline = new EGmap3Polyline(array('strokeColor' => 'orange'));
//$polyline->path = array(
//	array(25.774252, -80.190262),
//	array(23.1168, -82.3885569),
//	array(18.539269, -72.336408),
//);
////$polyline->centerOnMap();
////$gmap->add($polyline);
//
//$circleOptions = array_merge(
//		$polyOptions, array('radius' => 100000)
//);
//$circle = new EGmap3Circle($circleOptions);
//$circle->address = 'La Habana, Cuba';
////$circle->centerOnMap();
////$gmap->add($circle);
//
//$circle = new EGmap3Circle($circleOptions);
//$circle->address = 'Port-au-Prince, Haïti';
//$callback = 'function(circle){alert("circle center: "+circle.getCenter());}';
//$circle->addCallback($callback);
////$gmap->add($circle);
//
//// adding an info window automatically centers it on the map, overriding all other
//// centering calls
//$infoWindow = new EGmap3InfoWindow(
//				array('content' => 'Hospital')
//);
////$infoWindow->address = 'Chihuahua, México';
////$gmap->add($infoWindow);
//
//// adding a route automatically centers it on the map, overriding all other
//// centering calls
//$route = new EGmap3Route(array(
//			'origin' => 'New York, NY',
//			'destination' => 'Acapulco, México',
//		));
////$gmap->add($route);
//
//
?>

       </div>    
  